#include <iostream>
#include "protocol/include/log.hpp"
#include "protocol/include/MDQPParser.hpp"
#include "protocol/include/MIRPParser.hpp"
#include "protocol/include/Market.hpp"

Market::Market& getMarket()
{
    static Market::Market market;
    return market;
}



void parseTCPServer()
{
    MDQPParser mdqp_parser("/home/wang/Documents/github/internship/shang-hai-qi-huo/tcp_20230628.pcap");
    if (mdqp_parser.parse())
    {
        MDQPHeader *mdqp_header = mdqp_parser.getMDQP();
        while (mdqp_header)
        {
            getMarket().parseMDQP((uint8_t*)mdqp_header, sizeof(MDQPHeader) + mdqp_header->length);
            mdqp_header = mdqp_parser.getMDQP();
        }
    }
}


void parseUDPServer()
{
    MIRPParser mirp_parser("/home/wang/Documents/github/internship/shang-hai-qi-huo/udp.pcap");
    if (mirp_parser.parse())
    {
        MIRPHeader *mirp_header = mirp_parser.getMIRP();
        while (mirp_header)
        {
            getMarket().parseMIRP(mirp_header);
            mirp_header = mirp_parser.getMIRP();
        }
    }
}
int main(int argc, char const *argv[])
{
    parseTCPServer(); // 测试通过
    parseUDPServer(); // 测试通过
    return 0;
}
